package org.ruoyi.alibaba.chat.controller;


import org.ruoyi.alibaba.chat.entity.Message;
import org.ruoyi.alibaba.chat.service.AlibabaChatClient;
import org.ruoyi.alibaba.chat.service.AlibabaRagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/alibaba/chat")
public class AlibabaChatController {

    @Autowired
    private AlibabaChatClient chatClient;

    @Autowired
    private AlibabaRagService ragService;

    /**
     * 简单的聊天
     *
     * @param query
     * @return
     */
    @GetMapping("/simple")
    public String simpleChat(String query) {
        return chatClient.simple(query);
    }

    /**
     * 流式聊天
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/stream",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> streamChat(@RequestBody Message message) {
        return chatClient.stream(message.getContent(), "deepseek-r1");
    }

    @GetMapping("/rag")
    public String rag(){
        ragService.rag();
        return "123";
    }
}
